package com.vcms.controller.customer.states;

import com.vcms.controller.customer.TransactionController;
import com.vcms.controller.customer.DispenseController;
import com.vcms.controller.customer.CoinReceiver;
import com.vcms.controller.customer.states.TransactionState;

public class TerminateState extends TransactionState {

	public TerminateState(TransactionController transactionController){
		setTransactionController(transactionController);
	}
	
	@Override
	public boolean handleDisplayCustomerPanel() {
		System.out.println("[TerminateState] - Incorrect state to handle display customer panel!");
		
		return false;
	}
	
	@Override
	public boolean handleStartTransaction() {
		System.out.println("[TerminateState] - Incorrect state to handle start transaction!");
		
		return false;
	}
	
	@Override
	public boolean handleProcessMoneyReceived() {
		System.out.println("[TerminateState] - Incorrect state to handle process money received!");
		
		return false;
	}
	
	@Override
	public boolean handleCompleteTransaction() {
		System.out.println("[TerminateState] - Incorrect state to complete transaction!");
		
		return false;
	}
	
	@Override
	public boolean handleTerminateTransaction() {
		System.out.println("Inside Terminate State Handle - Terminate");
		
		TransactionController transactionController = this.getTransactionController();
		DispenseController dispenseController = transactionController.getDispenseController();
		CoinReceiver coinReceiver = transactionController.getCoinReceiver();
		
		//deactive drink selection
		dispenseController.allowSelection(false);
		//stop coin entry
		coinReceiver.stopReceive();
		//refund money so far entered
		coinReceiver.refundCash();
		
		return true;
	}
	
	@Override
	public boolean handleTerminateFault() {
		System.out.println("[TerminateState] - Incorrect state to handle terminate fault!");
		
		return false;
	}
	
	@Override
	public boolean handleRefreshCustomerPanel() {
		System.out.println("[TerminateState] - Incorrect state to handle refresh customer panel!");
		
		return false;
	}

	public void printState(){
		System.out.println("- Terminate State -");
	}
}
